<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:directive.page import="com.anhry.app.safety.util.Util"/>
<%@ include file="/WEB-INF/pages/share/taglib.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>用户修改</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="<%=basePath+Util.SKIN%>/css/right.css" type="text/css" rel="stylesheet">
	<script type="text/javascript" src="<%=basePath%>/js/jquery-1.7.2.js"></script>
	<script type="text/javascript" src="<%=basePath%>/js/check_jquery.js"></script>
	<script type="text/javascript" src="<%=path%>/js/selected.js"></script>
	<script type="text/javascript">
		var b = true;
		$(document).ready(function(){
			$("#bit1").blur(function() {
				var gs = encodeURI(encodeURI($("#bit1").val()));
				var objId = '${user.id }';
	    		if(gs==""){
		         $("#userSpan").html("用户名不能为空!").addClass("note5");
		         return false;
		        }
		        var urls="<%=basePath%>/admin/sys_userCheck.action?objId="+objId+"&userName="+gs;
				$.post(urls,function(data){
					if(data=="0"){
						$("#userSpan").html("<font color='green'>此用户可以使用！</font>");
						b = true;
						return true;
					}else if(data!="0"){
						$("#userSpan").html("该用户名已存在，请重新填写!").addClass("note5");
						b = false;
						return false;
					}
				});
			});
		});
    	$(function(){
			initSelArray('unitId:1','deptId:1','streetId:1');
			var cGrade = '${user.tbUserGrade.id}';
			var cUnit = '${user.tbUserUnit.id}';
			var cDept = '${user.tbUserDept.id}';
			var cStreet = '${user.tbUserStreet.id}';
			if(null!=cGrade && cGrade!=""){
				changeGrade(cGrade);
			}
	   		if(cUnit!=null && cUnit!=""){
	   			changeUnit(cUnit);
	   			selected('unitId',cUnit);	//加载选中部门
	   		}
	   		if(cDept!=null && cDept!=""){
	   			 changeDept(cDept);
	   			selected('deptId',cDept);	//加载选中单位
	   		}
	   		if(cStreet!=null && cStreet!=""){
	   			$("#countrySpan").css("display","");
	   			selected('streetId',cStreet);	
	   		}
		});
    	function toSubmit(){
    		if(!b){
    			alert('该用户名已存在，请重新填写!');
    			document.getElementById('userSpan').innerHTML='该用户名已存在，请重新填写!';
    			return false;
    		}
    		return true;
    	}
    	
       	function changeGrade(rid){
	   		var urls='<%=basePath%>/admin/sys_loadDept.action?gradeId='+rid
	   		buildSelect(rid, 'unitId',urls,'1');
	   		if(rid == 9) {
	   			$("#countrySpan").css("display","");
	   		} else {
	   			$("#countrySpan").css("display","none");
	   		}
	   	}
	   	function changeUnit(uid){
	   		var rid=document.getElementById("bselect1").value;
	   		var urls="<%=basePath%>/admin/sys_loadDept.action?unitId="+uid+"&gradeId="+rid;
	   		buildSelect(uid, 'deptId',urls,'1');
	   	}
	   	 	function changeDept(did){
	   		if(	$("#countrySpan").css("display") !="none") {
	   		var rid=document.getElementById("bselect1").value;
	   			var urls="<%=basePath%>/admin/sys_loadDept.action?unitId="+did+"&gradeId="+rid;
	   			buildSelect(did, 'streetId',urls,'1');
	   		}
	   	}
	</script>
  </head>
  
  <body>
	<div  class="body-box">
		<div class="map">
			<div class="map_con">
				您当前的位置：系统管理 &gt; 用户管理 &gt; 用户修改
			</div>
			
		</div>
		<div id="container">
			<form action="<%=basePath%>/admin/sys_userSave.action" method="post" name="form1">
		    	<table border="0" cellspacing="0" cellpadding="0"  width="100%" class="info_table">
					<tr>
						<td colspan="4" class="title_li">用户修改</td>
					</tr>
					<tr>
						<td width="15%" class="title_td">用户名：</td>
						<td colspan="3"><input type="text" name="userName" class="info_input" value="${user.userName }" id="bit1"/><SPAN class="note4" id="userSpan">*</SPAN></td>
					</tr>
					<tr>
						<td class="title_td">真实姓名：</td>
						<td><input type="text" name="userRealName" class="info_input" value="${user.userRealName }" id="bit3"/><SPAN class="note4">*</SPAN></td>
						<td class="title_td">性别：</td>
						<td><s:radio list="#{1:'男',0:'女'}" name="userSex" value="%{user.userSex}" theme="simple"></s:radio> </td>
					</tr>
					<tr>
						<td class="title_td">用户级别：</td>
						<td colspan="3"><s:select list="gradeList" name="gradeId" value="%{user.tbUserGrade.id}" listKey="id" listValue="gradeName" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;margin-left:5px;" id="bselect1" onchange="changeGrade(this.value);"></s:select><SPAN class="note4">*</SPAN></td>
					</tr>
					<tr>
						<td class="title_td">用户部门：</td>
						<td colspan="3">
							<s:select list="#{}" name="unitId" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;margin-left:5px;" id="bselect2" onchange="changeUnit(this.value);"></s:select><SPAN class="note4">*</SPAN>
							<s:select list="#{}" name="deptId" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;margin-left:5px;" onchange="changeDept(this.value);"></s:select>
							<span style="display: none;" id="countrySpan"> <s:select
										list="#{}" name="streetId" headerKey="" headerValue="请选择"
										theme="simple" cssStyle="width:155px;margin-left:5px;"></s:select>
								</span>
						</td>
					</tr>
					<tr>
						<td class="title_td">职务：</td>
						<td><s:select list="zwList" name="userZw" value="%{user.userZw}" listKey="id" listValue="name" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;margin-left:5px;" id="bselect5"></s:select><SPAN class="note4">*</SPAN></td>
						<td class="title_td">角色：</td>
						<td><s:select list="roleList" name="roleId" value="%{user.tbUserRole.id}" listKey="id" listValue="roleName" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;margin-left:5px;" id="bselect4"></s:select><SPAN class="note4">*</SPAN></td>
					</tr>
					<tr>
						<td class="title_td">手机：</td>
						<td><input type="text" name="userPhone" class="info_input" value="${user.userPhone }" id="tel1"/><SPAN class="note4"></SPAN></td>
						<td class="title_td">邮箱：</td>
						<td><input type="text" name="userEmail" class="info_input" value="${user.userEmail }" id="email1"/><SPAN class="note4"></SPAN></td>
					</tr>
					<tr>
						<td colspan="4" align="center">
							<center>
							<input type="submit" name="btntj" class="link_input" id="btnSubmit1" value="提 交" onclick="return toSubmit();">
							<input type="reset" name="btnset" class="link_input" id="btnset" value="重 置">
							<input type="button" name="btn1" class="link_input" id="btnset1" value="返 回" onclick="window.location.href='<%=basePath%>/admin/sys_userList.action?keyWord=${keyTemp}&cGrade=${cGrade }&cUnit=${cUnit }&cDept=${cDept }&cRole=${cRole }&cZw=${cZw }&num=${num }&size=${size }'">
							</center>
						</td>
					</tr>
				</table>
				<input type="hidden" name="objId" value="${user.id }"/>
				<input type="hidden" name="cGrade" value="${cGrade }"/>
				<input type="hidden" name="cUnit" value="${cUnit }"/>
				<input type="hidden" name="cDept" value="${cDept }"/>
				<input type="hidden" name="cRole" value="${cRole}"/>
				<input type="hidden" name="cZw" value="${cZw }"/>
				<input type="hidden" name="keyWord" value="${keyWord }"/>
			</form>
		</div>
	</div>
  </body>
</html>
